USE [C:\SOURCE\JAKKAJ\TECHED\HOOIZDAT\WEB\APP_DATA\HOOIZDAT.MDF]

SELECT 'INSERT INTO [dbo].[Character]([CharacterID],[Name]) VALUES(' + CONVERT(nvarchar, [CharacterID]) + ',''' + [Name] + ''')'
FROM [dbo].[Character]
GO

SELECT 'INSERT INTO [dbo].[Trait]([TraitID],[ParentTraitID],[Name],[QuestionFormat]) ' +
	   'VALUES(' + CONVERT(nvarchar, [TraitID]) + ',' + COALESCE(CONVERT(nvarchar, [ParentTraitID]),'NULL') + ',''' + [Name] + ''',''' + REPLACE([QuestionFormat], '''', '''''') + ''')'
FROM [dbo].[Trait]
ORDER BY [ParentTraitID]
GO

SELECT 'INSERT INTO [dbo].[TraitVariation]([TraitVariationID],[TraitID],[Name]) ' +
       'VALUES(' + CONVERT(nvarchar, TraitVariationID) + ',' + CONVERT(nvarchar, [TraitID]) + ',''' + [Name] + ''')'
FROM [dbo].[TraitVariation]
GO

SELECT 'INSERT INTO [dbo].[CharacterTrait]([CharacterID],[TraitID],[TraitVariationID]) ' +
       'VALUES(' + CONVERT(nvarchar, [CharacterID]) + ',' + CONVERT(nvarchar, [TraitID]) + ',' + COALESCE(CONVERT(nvarchar, TraitVariationID),'NULL') + ')'
FROM [dbo].[CharacterTrait]
GO
